package com.jinzhuo;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class workQueue {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory factory = new ConnectionFactory();
        factory.setVirtualHost("/jinzhuo");
        factory.setPort(5672);
        factory.setPassword("jinzhuo");
        factory.setUsername("jinzhuo");

        Connection connection = factory.newConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare("workQueue",true,false,false,null);

        for (int i = 0; i <10 ; i++) {
            String message="你好,第-"+i+"-条workQueue消息";
            channel.basicPublish("","workQueue",null,message.getBytes());
        }

        channel.close();
        connection.close();

    }
}
